/*
 * @Author: LIFM0623 1944099171@qq.com
 * @Date: 2024-01-12 21:45:09
 * @LastEditors: EyeSklear 1814580085@qq.com
 * @LastEditTime: 2024-01-22 16:41:47
 * @FilePath: \Scene_Back\src\marker\marker.module.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Module } from '@nestjs/common';
import { MarkerService } from './marker.service';
import { MarkerController } from './marker.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { marker } from './entities/marker.entity';
import { MulterModule } from '@nestjs/platform-express';
import { diskStorage } from 'multer';
import { extname } from 'path';
import * as path from 'path';
@Module({
  imports: [
    MulterModule.register({
      storage: diskStorage({
        destination: function (req, fileName, callback) {
          try {
            callback(null, path.resolve(process.env.FILE_PATH + '/marker'));
          } catch (error) {
            console.error('Error in setting marker destination:', error);
          }
        },
        filename: (_, file, callback) => {
          const fileName = `${
            new Date().getTime() + extname(file.originalname)
          }`;
          return callback(null, fileName);
        },
      }),
    }),
    TypeOrmModule.forFeature([marker]),
  ],
  controllers: [MarkerController],
  providers: [MarkerService],
  exports: [MarkerService],
})
export class MarkerModule {}
